﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RemotingApp
{

    public class MyJob : Quartz.IJob
    {

        public void Execute(Quartz.IJobExecutionContext context)
        {
            string url = context.JobDetail.JobDataMap.ElementAt(0).Value.ToString();

            string msg = ""
                + " At " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                + " ,  JobDataMap[0] URL : " + url.ToString()
                + "    " + context.JobDetail.Description;

            String path = AppDomain.CurrentDomain.BaseDirectory + "Job\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string v2 = context.JobDetail.JobDataMap.ElementAt(1).Value.ToString();
            File.AppendAllText(path + "job" + v2 + ".txt",
                msg + System.Environment.NewLine);



            System.Net.WebClient wc = new System.Net.WebClient();
            string html = wc.DownloadString(url);

            File.AppendAllText(path + "job" + v2 + ".txt",
                "  >> " + html + System.Environment.NewLine);
        }
    }
}
